package com.xxx.modules.controller;;
import com.xxx.modules.service.AdjustService;
import com.xxx.modules.entity.Adjust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * adjust
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2023-04-29
 */
@RestController
@RequestMapping("/common/adjust")
@Api(tags="adjust")
public class AdjustController {
    @Autowired
    private AdjustService adjustService;

    /**
    *  获取所有调剂信息
    * @param pageNum
    * @param pageSize
    * @param adjust
    * @return
    */

    @GetMapping("/getAdjustInfo")
    @ApiOperation("获取所有调剂信息")
    public Result getAdjustInfo(Adjust adjust, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Adjust> data = adjustService.selectAdjustInfo(adjust,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }


    @GetMapping("/getAdjustInfo2")
    @ApiOperation("获取所有推荐调剂信息")
    public Result getAdjustInfo2(Adjust adjust, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Adjust> data = adjustService.selectAdjustInfo2(adjust,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }
    /**
    * 保存调剂信息
    * @param adjust
    * @return
    */
    @PostMapping("/saveAdjustInfo")
    @ApiOperation("保存调剂信息")
    public Result saveAdjustInfo(@RequestBody Adjust adjust){
        adjustService.saveAdjustInfo(adjust);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新调剂信息
     * @param adjust
     * @return
     */

    @PutMapping("/updateAdjustInfo")
    @ApiOperation("更新调剂信息")
    public Result updateAdjustInfo(@RequestBody Adjust adjust){
        adjustService.updateAdjustInfo(adjust);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除调剂信息
     * @param id
     * @return
     */
    @DeleteMapping("/delAdjustInfo")
    @ApiOperation("根据id删除调剂信息")
    public Result delAdjustInfo(Integer id){
        adjustService.delAdjustInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除调剂信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchAdjustInfo")
    @ApiOperation("根据id集合批量删除调剂信息")
    public Result delBatchAdjustInfo(String idList){
        adjustService.delBatchAdjustInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}